<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
$api = app('Dingo\Api\Routing\Router');

$api->version('v1', function ($api)
{
    $api->group(['namespace' => 'App\Http\Controllers'], function ($api)
    {
        $api->get('indexData','ApiController@indexData'); //获取indexData数据
        $api->get('articleInfo/{id}','ApiController@articleInfo'); //获取文章详情接口
        $api->get('hotData/{page?}','ApiController@hotData'); //获取发型热点5条数据
        $api->get('hotDataHtml/{page?}','ApiController@hotDataHtml');
        $api->get('tuoFaData/{page?}','ApiController@tuoFaData'); //获取脱发5条数据
        $api->get('tuoFaDataHtml/{page?}','ApiController@tuoFaDataHtml');
        $api->get('yangFaData/{page?}','ApiController@yangFaData'); //获取养发5条数据
        $api->get('yangFaDataHtml/{page?}','ApiController@yangFaDataHtml');
        $api->get('zhiFaData/{page?}','ApiController@zhiFaData'); //获取植发5条数据
        $api->get('zhiFaDataHtml/{page?}','ApiController@zhiFaDataHtml');
        $api->get('faXingData/{page?}','ApiController@faXingData'); //获取发型5条数据
        $api->get('faXingDataHtml/{page?}','ApiController@faXingDataHtml');
        $api->get('articleList/{classid?}/{page?}','ApiController@articleList'); //获取二级栏目数据
        $api->get('more/{classid?}/{page?}','ApiController@more'); //获取二级栏目数据
    });
    //调查问卷模块
    $api->group(['namespace' => 'App\Http\Controllers\Api','prefix' => 'question'], function ($api)
    {
        $api->get('index','QuestionController@index'); //获取indexData数据
        $api->post('store','QuestionController@store'); //获取indexData数据
        $api->get('code','QuestionController@code'); //获取indexData数据
        $api->get('todo','QuestionController@todo'); //获取indexData数据
    });

    $api->group(['namespace' => 'App\Http\Controllers\Api','prefix' => 'Empire','middleware' => ['enable_cross']], function ($api)
    {
        $api->post('addComment', 'EmpireController@addComment'); //添加一条评论
        $api->get('index/{id}/{page?}', 'EmpireController@index'); //列表数据
        $api->get('yzm/{tel?}', 'EmpireController@yzm'); //验证码
        $api->get('zan/{id?}', 'EmpireController@zan'); //评论点赞
    });

    $api->group(['namespace' => 'App\Http\Controllers\Api','middleware' => ['enable_cross']], function ($api)
    {
        $api->get('todos', function (){
            return response()->json([
                ['id' => 1, 'title' => 'learn vue1', 'completed' => true],
                ['id' => 2, 'title' => 'learn vue2', 'completed' => false],
                ['id' => 3, 'title' => 'learn vue3', 'completed' => true]
            ]);
        }); //评论点赞
    });

});

$api->version('v2', function ($api)
{
    $api->group(['namespace' => 'App\Http\Controllers'], function ($api)
    {
        $api->get('show','ApiController@show');
    });
});
